﻿using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using External.Controls.ModelViews;
using External.Core;

namespace External.Controls
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region ТЕСТОВЫЕ ДАННЫЕ

            Hall hall = new Hall();

            Section a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15;

            //Красные секции
            hall.Sections.Add(a0 = new Section("Секция A-0", 490, 100, Brushes.Pink, new[] { 0, 0, 200, 0, 200, 150, 50, 150 }));
            hall.Sections.Add(a1 = new Section("Секция A-1", 700, 100, Brushes.Pink, new[] { 0, 0, 200, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a2 = new Section("Секция A-2", 910, 100, Brushes.Pink, new[] { 0, 0, 200, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a3 = new Section("Секция A-3", 1120, 100, Brushes.Pink, new[] { 0, 0, 200, 0, 150, 150, 0, 150 }));
            hall.Sections.Add(a4 = new Section("Секция A-4", 1280, 100, Brushes.LightGreen, new[] { 0, 150, 50, 0, 200, 150, 50, 200 }));
            hall.Sections.Add(a5 = new Section("Секция A-5", 1330, 260, Brushes.LightGreen, new[] { 0, 50, 150, 0, 150, 200, 0, 200 }));
            hall.Sections.Add(a6 = new Section("Секция A-6", 1330, 470, Brushes.LightGreen, new[] { 0, 0, 150, 0, 150, 200, 0, 150 }));
            hall.Sections.Add(a7 = new Section("Секция A-7", 1280, 630, Brushes.LightGreen, new[] { 50, 0, 200, 50, 50, 200, 0, 50 }));
            hall.Sections.Add(a8 = new Section("Секция A-8", 1120, 680, Brushes.SkyBlue, new[] { 0, 0, 150, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a9 = new Section("Секция A-9", 910, 680, Brushes.SkyBlue, new[] { 0, 0, 200, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a10 = new Section("Секция A-10", 700, 680, Brushes.SkyBlue, new[] { 0, 0, 200, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a11 = new Section("Секция A-11", 490, 680, Brushes.SkyBlue, new[] { 50, 0, 200, 0, 200, 150, 0, 150 }));
            hall.Sections.Add(a12 = new Section("Секция A-12", 330, 630, Brushes.Violet, new[] { 0, 50, 150, 0, 200, 50, 150, 200 }));
            hall.Sections.Add(a13 = new Section("Секция A-13", 330, 470, Brushes.Violet, new[] { 0, 0, 150, 0, 150, 150, 0, 200 }));
            hall.Sections.Add(a14 = new Section("Секция A-14", 330, 260, Brushes.Violet, new[] { 0, 0, 150, 50, 150, 200, 0, 200 }));
            hall.Sections.Add(a15 = new Section("Секция A-15", 330, 100, Brushes.Violet, new[] { 0, 150, 150, 0, 200, 150, 150, 200 }));

            int shiftX = 460;
            int shiftY = 150;
            int dx = 10;
            int dy = 5;
            for (int i = 0; i < 20; i++)
            {
                for (int j = 0; j < Enum.GetValues(typeof(SeatState)).Length; j++)
                {
                    Seat seat = new Seat();
                    seat.Number = i;
                    seat.Row = j;

                    seat.Left = shiftX + i*40 + i*dx;
                    seat.Top = shiftY + j*40 + j*dy;

                    seat.State = (SeatState)(j % 13);

                    a1.Seats.Add(seat);
                }
            }

            //Обертываем во ViewModel
            hallControl.Canvas.SelectedScheme = new HallViewModel(hall); 

            #endregion
            
            //Отображаем координаты
            MouseMove += MainWindowMouseMove;
        }

        private void MainWindowMouseMove(object sender, MouseEventArgs e)
        {
            Title = string.Format("X: {0} Y: {1}", e.GetPosition(this).X, e.GetPosition(this).Y);
        }
    }
}
